/* 
 *   Date       Developer   Description
 *   
 *
 *   Classname:  zzz.test.component.mina2.test01.client.Test01
 * 
 *   Date:   2014-3-16
 * 
 *   The source code contained in this listing is proprietary to
 *   HLJ POST YITONG INFO-NET CO.,LTD.
 * 
 *   Unauthorized copying, adaptation, distribution, use, or display
 *   is strictly prohibited.
 *   This software is Copyright 2014 HLJ POST YITONG INFO-NET CO.,LTD.
 */
package com.titan.demo.camel.sample.component.mina2.test01.client;

import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;

import com.titan.demo.camel.sample.component.mina2.test01.common.dto.PhoneMessageDto;
import com.titan.demo.camel.utils.CamelUtils;


/**
 *
 *
 * @author Administrator
 *
 */
public class Test01 {

    public static void main(String[] args) {
        CamelContext context = null;
        ProducerTemplate template = null;
        try {
            context = new DefaultCamelContext();
            context.addRoutes(new RouteBuilder() {
                public void configure() {
                    from("direct:start")
                    .to("mina2:tcp://localhost:3005?textline=false&sync=true&disconnect=false")
                    .to(CamelUtils.log("a"));
                }
            });
            
            template = context.createProducerTemplate();
            template.start();
            context.start();

            PhoneMessageDto sendMes = new PhoneMessageDto();
            sendMes.setSendPhone("13681803609"); // 当前发送人的手机号码
            sendMes.setReceivePhone("13721427169"); // 接收人手机号码
            sendMes.setMessage("测试发送短信，这个是短信信息哦，当然长度是有限制的哦....");
            
            template.sendBody("direct:start", sendMes);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            CamelUtils.close(template);
            CamelUtils.close(context);
        }        
    }

}

